﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AdHocSqlForm.aspx.cs" Inherits="AdHocSqlForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Adhoc SQL Queries</title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="left">
    <table>
        <tr>
            <td align="left">
                <table cellspacing="2" cellpadding="2" style="width:500px;">
                    <tr>
                        <td align="center">
                            <asp:Label ID="lblHeading" Font-Bold="True" Font-Size="Medium" runat="server" Text="Adhoc Sql Query Form"></asp:Label>
                            <br /><br />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td valign="top">
                <table cellspacing="2" cellpadding="2" style=" border:solid 1px black; width:500px;">
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblSelectConnection" runat="server" Font-Bold="True" Font-Size="Small" Text="Select Connection:"></asp:Label>
                        </td>
                        <td align="left">
                            <asp:DropDownList AutoPostBack="False" ID="ddlConnection" runat="server" DataTextField="Name" DataValueField="Name"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="left">
                            <asp:Label ID="lblSelectQuery" runat="server" Font-Bold="True" Font-Size="Small" Text="Select Query:"></asp:Label>
                        </td>
                        <td align="left">
                            <asp:DropDownList AutoPostBack="True" ID="ddlQuery" runat="server" 
                                DataTextField="Title" DataValueField="Title" 
                                onselectedindexchanged="ddlQuery_SelectedIndexChanged"></asp:DropDownList>
                        </td>
                    </tr>
                </table>
                <asp:Panel ID="pnlParameters" runat="server">
                </asp:Panel>
                <table cellspacing="2" cellpadding="2" style="width:500px;">
                    <tr>
                        <td colspan="2" align="center">
                            <asp:Label ID="lblError" ForeColor="Red" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" width="50%">
                            <asp:Button ID="btnReset" OnClick="Button_Click" runat="server" Text="Reset" />
                        </td>
                        <td align="center" width="50%">
                            <asp:Button ID="btnSubmit" OnClick="Button_Click" runat="server" Text="Submit" />
                        </td>
                    </tr>
                </table>
                <asp:Panel ID="pnlResults" runat="server" Visible="false">
                    <br />
                    <asp:GridView AutoGenerateColumns="true" ID="gvResults" runat="server" AllowPaging="False" AllowSorting="False">
                        <AlternatingRowStyle BackColor="LightGray" />
                        <HeaderStyle BackColor="Gray" ForeColor="White" />
                    </asp:GridView>
                    <br />
                    <table cellspacing="2" cellpadding="2" style="width:500px;">
                        <tr>
                            <td align="center">
                                <asp:Button ID="btnToCsv" OnClientClick="return OpenWindowForExport();" runat="server" Text="Convert to CSV" Visible="false" />
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
    </table>
    </div>
    </form>
</body>
</html>
